
import axios from '@/api/fetch';
import SERVER from '@/api/server'

//展厅接待
// 查询所有信息
export const queryReceptionistInfo = params =>{
    if(params.arriveDateEnd || params.arriveDateStart ){
        [1,2,3,4,5,6,7,8,9].forEach(x=>{
            let arriveDateEndM=''
            let arriveDateStartM=''
            if(params.arriveDateEnd.split('-')[1] == x && params.arriveDateEnd.split('-')[1].length == 1){
                arriveDateEndM = '0'+params.arriveDateEnd.split('-')[1]
                params.arriveDateEnd = `${params.arriveDateEnd.split('-')[0]}-${arriveDateEndM}-${params.arriveDateEnd.split('-')[2]}`
            }

            if(params.arriveDateStart.split('-')[1] == x && params.arriveDateStart.split('-')[1].length ==1){
                arriveDateStartM = '0'+params.arriveDateStart.split('-')[1]
                params.arriveDateStart = `${params.arriveDateStart.split('-')[0]}-${arriveDateStartM}-${params.arriveDateStart.split('-')[2]}`
            }

        })
       return axios.get(`${SERVER.CYXDMS_CLUE}/receptionist/queryReceptionistInfo`,{params})
    }else{
       return axios.get(`${SERVER.CYXDMS_CLUE}/receptionist/queryReceptionistInfo`,{params})
    }
    
};

//新增
export const saveReceptionist = params => axios.post(`${SERVER.CYXDMS_CLUE}/receptionist/saveReceptionist`, params);

//编辑
export const updateReceptionById = ( id , params) => axios.put(`${SERVER.CYXDMS_CLUE}/receptionist/updateReceptionById/${id}`, params );

//查询展厅顾问
export const getUserInfoByRolePosition = params => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/basedata/roles/getUserInfoByRolePosition`,{params});
export const getUsersByPosition = params => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/basedata/users/getUsersByPosition`,{params});

// 获取用户信息
export const getUserInfo = () => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/commonDatas`);
//获取顶部数据
export const getTodayInvite = () => axios.get(`${SERVER.CYXDMS_CLUE}/receptionist/todayInvite`);
export const getFastGoShoup = () => axios.get(`${SERVER.CYXDMS_CLUE}/receptionist/fastGoShoup`);

//根据手机号获取相关信息
export const getInfomationByMobile = (mobilePhone) => axios.get(`${SERVER.CYXDMS_CLUE}/receptionist/getInformationByMobile?mobilePhone=${mobilePhone}`,);
//导出
// export const  = params => axios.get(`${SERVER.CYXDMS_CLUE}/receptionist/exportFlowList`,{params});
export const exportFlowList = params => {
  return axios({
      url:`${SERVER.CYXDMS_CLUE}/receptionist/exportFlowList`,
      method:'get',
      params:params,
      responseType: 'blob'
  });
};

//不建档
export const updateDisposeStatusById = params => axios.get(`${SERVER.CYXDMS_CLUE}/receptionist/updateDisposeStatusById`,{params});

//查询是否有其他角色
export const getPositions = params => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/basedata/positions/getPositions`,{params});





